home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / PrimaryColors.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1999-08-13  |  4.0 KB  |  165 lines

  1. /*
  2.  
  3.    v1.83 PrimaryColors
  4.  
  5.    Marko Seppänen
  6.    marko.seppanen@wwnet.fi
  7.  
  8. */
  9.  
  10. address IMAGEENGINEER
  11.  
  12. Options results
  13. signal on error            /* Setup a place for errors to go */
  14.  
  15. if arg()=0 then exit
  16. x=arg(1)
  17. parse var x pic pcolor contr .
  18.  
  19.  
  20.  
  21. MARK pic PRIMARY
  22.  
  23. PROJECT_INFO pic TYPE
  24. info=result
  25. if info~='COLOUR' then do
  26.   CONVERT_TO_COLOUR pic
  27.   x0=RESULT
  28. end
  29. else do
  30.   CONVERT_TO_GREY pic
  31.   tmp=result
  32.   CONVERT_TO_COLOUR tmp
  33.   x0=result
  34.   CLOSE tmp
  35. end
  36.  
  37.  
  38.  
  39.  
  40. if pcolor~=="" then do
  41.  
  42.   if upper(pcolor)=="RANDOM" then do
  43.  
  44.     x = random(1,12,time('S'))
  45.  
  46.     if x="1" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 0 0'
  47.     if x="2" then 'COLOUR_FILTER' x0 'RGB 255 0 255 0 0 0'
  48.     if x="3" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 0 0'
  49.     if x="4" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 255 0'
  50.     if x="5" then 'COLOUR_FILTER' x0 'RGB 0 0 0 0 255 0'
  51.     if x="6" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 255 0'
  52.     if x="7" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 255 0'
  53.     if x="8" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 0 0'
  54.     if x="9" then 'COLOUR_FILTER' x0 'RGB 255 0 125 0 0 0'
  55.     if x="10" then 'COLOUR_FILTER' x0 'RGB 100 0 0 0 0 0'
  56.     if x="11" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 -128 0'
  57.     if x="12" then 'COLOUR_FILTER' x0 'RGB 255 0 200 0 255 0'
  58.  
  59.   end
  60.  
  61. end
  62.  
  63. else do
  64.  
  65.   if exists("ie:prefs/veprimarycolors.cfg") == "1" then
  66.     do
  67.       call open("temp","ie:prefs/veprimarycolors.cfg","R")
  68.       values=readln("temp")
  69.       parse var values ok color contr .
  70.       call close("temp")
  71.     end
  72.   else
  73.     do
  74.       color=0
  75.       contr=1
  76.     end
  77.  
  78.   'FORM "Primary Colors" "Use|Cancel"',
  79.   'CYCLE,"Choose color","DRed|Yellow|Green|LBlue|DBlue|Violet|Blue|DGreen|Brown|Red|Orange|Pink",'color'',
  80.   'CHECKBOX,"Contrast Stretch",'contr''
  81.  
  82.   values=result
  83.   parse var values ok color contr .
  84.  
  85.   if ok = 0 then exit
  86.  
  87.   call open("temp","ie:prefs/veprimarycolors.cfg","W")
  88.   res=writeln("temp",values)
  89.   call close("temp")
  90.  
  91. end
  92.  
  93.  
  94.  
  95. if upper(pcolor)~=="RANDOM" then do
  96.  
  97.   select
  98.  
  99.   when color == "0" | pcolor == "0" | upper(pcolor) == "DRED" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 0 0'
  100.   when color == "1" | pcolor == "1" | upper(pcolor) == "YELLOW" then 'COLOUR_FILTER' x0 'RGB 255 0 255 0 0 0'
  101.   when color == "2" | pcolor == "2" | upper(pcolor) == "GREEN" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 0 0'
  102.   when color == "3" | pcolor == "3" | upper(pcolor) == "LBLUE" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 255 0'
  103.   when color == "4" | pcolor == "4" | upper(pcolor) == "DBLUE" then 'COLOUR_FILTER' x0 'RGB 0 0 0 0 255 0'
  104.   when color == "5" | pcolor == "5" | upper(pcolor) == "VIOLET" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 255 0'
  105.   when color == "6" | pcolor == "6" | upper(pcolor) == "BLUE" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 255 0'
  106.   when color == "7" | pcolor == "7" | upper(pcolor) == "DGREEN" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 0 0'
  107.   when color == "8" | pcolor == "8" | upper(pcolor) == "BROWN" then 'COLOUR_FILTER' x0 'RGB 255 0 125 0 0 0'
  108.   when color == "9" | pcolor == "9" | upper(pcolor) == "RED" then 'COLOUR_FILTER' x0 'RGB 100 0 0 0 0 0'
  109.   when color == "10" | pcolor == "10" | upper(pcolor) == "ORANGE" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 -128 0'
  110.   when color == "11" | pcolor == "11" | upper(pcolor) == "PINK" then 'COLOUR_FILTER' x0 'RGB 255 0 200 0 255 0'
  111.  
  112.   otherwise BRIGHTNESS x0 "-255"
  113.  
  114.   end
  115.  
  116. end
  117.  
  118. col=result
  119. CLOSE x0
  120.  
  121. if contr == "1" then CALL Contr col
  122.  
  123.  
  124. exit
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. Contr:
  133.  
  134.   x1=arg(1)
  135.  
  136.   CONTRAST_STRETCH x1
  137.   x2=result
  138.   CLOSE x1
  139.  
  140.   CONTRAST x2 20
  141.   CLOSE x2
  142.  
  143. Return
  144.  
  145.  
  146. exit
  147.  
  148. /*******************************************************************/
  149. /* This is where control goes when an error code is returned by IE */
  150. /* It puts up a message saying what happened and on which line     */
  151. /*******************************************************************/
  152. error:
  153. if RC=5 then do            /* Did the user just cancel us? */
  154.     IE_TO_FRONT
  155.     LAST_ERROR
  156.     'REQUEST "'||RESULT||'"'
  157.     exit
  158. end
  159. else do
  160.     IE_TO_FRONT
  161.     LAST_ERROR
  162.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  163.     exit
  164. end
  165.